home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / G4C / CED / SC.gc < prev    next >
Encoding:
Gui4CLI script  |  1999-11-24  |  7.6 KB  |  346 lines

  1. G4C
  2.  
  3. WINBIG 56 47 542 156 'SAS C Programming GUI'
  4. WinType 11110001
  5. resinfo 8 640 256
  6. winout 'NIL:'    ; no shell output..
  7.  
  8. xOnLoad file
  9.     ; assign sc if not assigned..
  10.     ifexists assign ~sc
  11.         ifexists directory hard:prog/sc
  12.             assign sc: hard:prog/sc    ; me..
  13.         else
  14.             temp = ''
  15.             reqfile -1 -1 300 -40 'Where is the SC directory?' DIR temp sys:
  16.             if $temp = ''
  17.                 guiopen #this
  18.                 stop
  19.             endif
  20.             assign sc: $temp
  21.         endif
  22.         assign lib: sc:lib
  23.         assign include: sc:include
  24.         cli 'path sc:c add'
  25.     endif
  26.     setgad #this 91 hide    ; hide lv
  27.     GuiOpen #This
  28.  
  29. xOnReload file
  30.     GuiOpen #This
  31.  
  32. xOnClose ; quit if running alone..
  33.     ifexists gui ~cedbar.gc
  34.         GuiQuit #This
  35.     endif
  36.  
  37. xOnQuit
  38.     GuiQuit sc.dcpop
  39.  
  40. xOnFail
  41.     guiopen #this
  42.     guiscreen #this front
  43.     speak 'Operation failed!'
  44.     lvuse #this 1
  45.     lvadd 'Operation failed.'
  46.  
  47. ; =======================================================
  48. ; -- the pipe event where the output is piped at
  49. ; =======================================================
  50.  
  51. xPipe pipe:SC_RES ON
  52.     gadid 2
  53.     lvuse #this 1        ; whenever a line is available
  54.     lvadd $$pipe        ; append it to our listv
  55.  
  56. ; =======================================================
  57. ;    Main LV
  58. ; =======================================================
  59.  
  60. XLISTVIEW 0 15 540 141 "" item "" 10 MULTI
  61.     gadid 1
  62.     attr resize 0022
  63.     gadfont #mono 8 000
  64.     local name/line/type/tnum
  65.  
  66.     ; parse the line
  67.     cutvar item copy word 4 line
  68.     parsevar line
  69.     name = $$parse.0
  70.     line = $$parse.1
  71.     type = $$parse.2
  72.     tnum = $$parse.3
  73.     if $type == 'Warning'
  74.     or $type == 'Error'
  75.         guiopen sc.dcpop $fpath $name $line $type $tnum
  76.     endif
  77.  
  78. ; data lv
  79. XLISTVIEW 0 0 542 156 "" hlv "" 0 DIR
  80.     gadid 91
  81.  
  82. ; =======================================================
  83. ;    Icons
  84. ; =======================================================
  85.  
  86. ; ============================= sc xx genprotos
  87.  
  88. XICON 0 0 :icons/GenProtos
  89.     attr resize 0000
  90.     if $fname = ''
  91.         gosub #this getfile
  92.     endif
  93.     if $fname > ''
  94.         lvuse #this 1
  95.         lvadd 'Generating protos for $fname '
  96.         ; run 'sc >pipe:SC_RES $fname genprotos'
  97.         launch 1 'sc >pipe:SC_RES $fname genprotos'
  98.     endif
  99.  
  100. ; ============================= sc xx link
  101.  
  102. XICON 25 0 :icons/Compile
  103.     attr resize 0000
  104.     if $fname = ''
  105.         gosub #this getfile
  106.     endif
  107.     if $fname > ''
  108.         lvuse #this 1
  109.         lvadd 'Compiling $fname '
  110.         ; run 'sc >pipe:SC_RES $fname link'
  111.         launch 1 'sc >pipe:SC_RES $fname link'
  112.     endif
  113.  
  114. ; ------ Return from Compile and GenProtos
  115.  
  116. xOnReturn 1
  117.     guiopen #this
  118.     guiscreen #this front
  119.     speak 'Operation finished!'
  120.     lvuse #this 1
  121.     lvadd 'Operation finished.'
  122.  
  123. ; ============================= file to compile
  124.  
  125. XTEXTIN 50 0 88 14 "" fname '' 100
  126.     gadid 3
  127.     attr resize 0000
  128.  
  129. ; ============================= choose file (will cd to it's dir)
  130.  
  131. XICON 140 0 :icons/Open
  132.     attr resize 0000
  133.     gosub #this getfile
  134.  
  135. ; ============================= Open shell on the front screen
  136.  
  137. XICON 190 0 :icons/Shell
  138.     attr resize 0000
  139.     shell = $$g4c.output        ; the default shell type
  140.     extract shell unquote shell
  141.     shell = '\"$shell\/SCREEN $$sys.fsn\"'
  142.     run 'newshell $shell'
  143.  
  144. ; ============================= Open dir.gc
  145.  
  146. XICON 215 0 :icons/Dir
  147.     attr resize 0000
  148.     guiclose dir.gc
  149.     guiload guis:dir/dir.gc
  150.     lvuse dir.gc 1
  151.     if $$lv.dir = ''        ; 
  152.         if $fpath > ''
  153.             lvdir #$fpath
  154.         endif
  155.     endif
  156.  
  157. ; ============================= Clear LV
  158.  
  159. XICON 165 0 :icons/Clear
  160.     attr resize 0000
  161.     lvuse #this 1
  162.     lvclear
  163.  
  164. ; ============================= Get C functions
  165.  
  166. XICON 240 0 :icons/Functions
  167.     attr resize 0000
  168.     funcfile = ''
  169.     ReqFile -1 -1 300 -40 'Choose C file:' LOAD funcfile $fpath
  170.     if $funcfile > ''
  171.         cli 'getfunc >pipe:SC_RES $funcfile'
  172.     endif
  173.  
  174. ; ============================= Break sc
  175.  
  176. XICON 265 0 :icons/Quit
  177.     attr resize 0000
  178.     BreakTask 'sc' C
  179.     lvuse #this 1
  180.     lvadd 'Aborted operation.'
  181.  
  182. ; =======================================================
  183. ;    Menus
  184. ; =======================================================
  185.  
  186. xMenu Project Open.. '' 'O'
  187.     gosub #this getfile
  188.  
  189. xMenu Project BARLABEL '' ''
  190.  
  191. xMenu Project 'About..' '' ''
  192.     ezreq 'SC.gc - 1.0 - by dck@hol.gr\n\nA simple gui for the\nSAS C development system' 'OK' ''
  193.  
  194. xMenu Project 'Quit' 'SC.gc' ''
  195.     guiquit #this
  196.  
  197. xMenu Project 'Quit' 'CedBar.gc' ''
  198.     guiquit cedbar.gc
  199.  
  200. xMenu Project 'Quit' 'Gui4Cli (all)' ''
  201.     ezreq 'Quit Gui4Cli ?' 'YES|CANCEL' choice
  202.     if $choice = 1
  203.         quit
  204.     endif
  205.  
  206. ; ======================= Edit
  207.  
  208. xMenu Edit 'Clear list' '' 'C'
  209.     lvuse #this 1
  210.     lvclear
  211.  
  212. xMenu Edit 'Clear Selected' '' ''
  213.     lvuse #this 1
  214.     guiwindow #this wait
  215.     setgad #this 1 HIDE        ; hide lv for speed..
  216.     lvmulti first
  217.     while $$lv.line > ''
  218.         lvdel -1
  219.         lvmulti first
  220.     endwhile    
  221.     setgad #this 1 SHOW
  222.     guiwindow #this resume
  223.     lvmulti show
  224.  
  225. xMenu Edit 'Select all' '' 'A'
  226.     lvuse #this 1
  227.     lvmulti all
  228.  
  229. xMenu Edit 'Un-Select all' '' 'N'
  230.     lvuse #this 1
  231.     lvmulti none
  232.  
  233. xMenu Edit BARLABEL '' ''
  234.  
  235. xMenu Edit 'MakeID Selection' '' ''
  236.     ; get selected text
  237.     SendRexx $cedport cut
  238.     lvuse CedClip.g 1
  239.     lvchange 'CLIPS:$cedClip'
  240.     txt = $$lv.rec
  241.     sendrexx $cedport "text #define $txt\tMakeID(\'$txt[0][1]\',\'$txt[1][1]\',\'$txt[2][1]\',\'$txt[3][1]\')\t\t// "
  242.  
  243. ; =======================================================
  244. ;    Routines
  245. ; =======================================================
  246.  
  247. xRoutine GetFile        ; get a file
  248.     local dir
  249.     if $fname = ''
  250.         ifexists gui cedbar.gc
  251.             ; get the current filename so we can get it's path
  252.             sendrexx $cedbar.gc/cedport 'status filename'
  253.             dir = $$rexxret
  254.             extract dir path dir
  255.         endif
  256.     endif
  257.     newfile = ''
  258.     reqfile -1 -1 300 -40 'Choose C source file:' LOAD newfile $dir
  259.     if $newfile > ''
  260.         file = $newfile
  261.         extract file ext fext
  262.         if $fext !! '.c'
  263.             ezreq 'Please choose a C file' OK ''
  264.             stop
  265.         endif
  266.         extract file file fname
  267.         extract file path fpath
  268.         cd $fpath
  269.         setwintitle #this 'DIR: $fpath'
  270.         update #this 3 $fname
  271.     endif
  272.  
  273.  
  274. ; &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  275. ; ====================================================================
  276.     NewFile sc.dcpop    ; pop-up on doubleclick
  277. ; ====================================================================
  278. ; &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  279.  
  280. WinBig 0 0 80 90 ""
  281. WinType 00001000
  282. winonmouse 30 7 
  283.  
  284. ; FullPath FileName LineNumber TypeOfErrorOrWarning Number
  285. xOnOpen fpath fname lnum type tnum
  286.     joinfile $fpath $fname file
  287.  
  288. xOnRMB
  289.     guiclose #This
  290. xOnInactive
  291.     guiclose #This
  292. xOnFail
  293.     ezreq "Error during operation" OK ""
  294.  
  295. xBefore    ; before every action...
  296.     GuiClose #this
  297.     ; if cedbar is not running, fire it up..
  298.     ifexists gui ~cedbar.gc
  299.         guiload sq1:guis/cedbar/cedbar.gc
  300.     endif
  301.  
  302. ; ================================================================
  303. ;            Buttons
  304. ; ================================================================
  305. ; ======================== Goto error line
  306.  
  307. xbutton 0 0 0 15 '-> Line'
  308.     guiscreen cedbar.gc front
  309.     sendrexx $cedbar.gc/cedport 'jump to file $file'
  310.     if $$rexxret = 0    ; file not loaded
  311.         sendrexx $cedbar.gc/cedport 'open new'
  312.         sendrexx $cedbar.gc/cedport 'open $file' ; full path..
  313.     endif
  314.     sendrexx $cedbar.gc/cedport 'expand view'
  315.     sendrexx $cedbar.gc/cedport 'jump to line $lnum'
  316.     
  317. ; ======================== Goto error number (in sc guide)
  318.  
  319. xbutton 0 15 0 15 '-> Error'
  320.     ; if our amigaguide is not runing, start it
  321.     ifexists port ~SCAGUIDE
  322.         run 'amigaguide sc:help/scmsg.guide screen=$$sys.fsn port=SCAGUIDE'
  323.         wait port SCAGUIDE 30
  324.         if $$retcode > 0
  325.             ezreq "Couldn't find the AmigaGuide\nprogram in your path!" OK ''
  326.             stop
  327.         endif
  328.     endif
  329.     ; make ag node name for error - must be 005 or 112 or 095
  330.     cutvar tnum cut char -1 '' ; cut off the ':'
  331.     err = '000'
  332.     info variable tnum
  333.     len = $$var.length
  334.     c = $(3 - $len)
  335.     err[$c][$len] = $tnum
  336.     sendrexx SCAGUIDE 'LINK sc:help/scmsg.guide/scm$err'
  337.  
  338. xbutton 0 30 0 15 ''
  339.  
  340. xbutton 0 45 0 15 ''
  341.  
  342. xbutton 0 60 0 15 ''
  343.  
  344. xbutton 0 75 0 15 ''
  345.  
  346.